package com.woniu.orderservice.service.impl;
import com.woniu.orderservice.config.Validateutil;
import com.woniu.orderservice.dao.OrderinfosDao;
import com.woniu.orderservice.entity.Orderinfos;
import com.woniu.orderservice.entity.Orders;
import com.woniu.orderservice.dao.OrdersDao;
import com.woniu.orderservice.service.OrdersService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("ordersService")
public class OrdersServiceImpl implements OrdersService {

    @Resource
    private OrdersDao ordersDao;

    @Resource
    private OrderinfosDao ordersinfosDao;

    @Resource
    private Validateutil validateutil;

    @Override
    public Orders queryById(Integer id) {
        return ordersDao.queryById(id);
    }

    @Override
    public List<Orders> queryAllByLimit(int offset, int limit) {
        return ordersDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<Orders> findAll() {
        return ordersDao.findAll();
    }

    @Override
    public Orders insert(Orders orders) {
        ordersDao.insert(orders);
        return orders;
    }

    @Override
    public Orders update(Orders orders) {
        ordersDao.update(orders);
        return queryById(orders.getId());
    }

    @Override
    public boolean deleteById(Integer id) {
        return ordersDao.deleteById(id) > 0;

    }


    @Override
    public Orders queryAllById(Integer id) {
        return ordersDao.queryAllById(id);
    }

    @Override
    public List<Orders> queryByUserId(Integer userId) {
        return ordersDao.queryByUserId(userId);
    }

    @Override
    public Orders findOrderByOrderNo(String orderNo) {
        return ordersDao.findOrderByOrderNo(orderNo);
    }

    @Override
    public List<Orderinfos> findOrderItems(Integer id) {
        return ordersinfosDao.findOrderItemsByOrderId(id);
    }

    @Override
    public List<Orders> queryAllByUserId(Integer userId) {
        return ordersDao.queryAllByUserId(userId);
    }

}